/**
 * 
 */
package three_star_craft.uap.event;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.grlea.log.SimpleLogger;

import three_star_craft.EventData;
import three_star_craft.uap.UapSigNo;
import UserApplicationPart.UAP.UapMediaBearerSetupConfirm;

/**
 * @author w.antosiewic
 *
 */
public class EventUapMediaBearerSetupCfm extends EventData
{
    private static final SimpleLogger logger = new SimpleLogger(EventUapMediaBearerSetupCfm.class);
    
    private UapMediaBearerSetupConfirm _mbSetupCfm;
    
	public EventUapMediaBearerSetupCfm(UapMediaBearerSetupConfirm mbSetupCfm)
	{
		super(UapSigNo.UAP_MEDIA_BEARER_SETUP_CFM);
		_mbSetupCfm = mbSetupCfm;
		if(!_mbSetupCfm.isInitialized())
		{
		    logger.error("Message EventUapMediaBearerSetupCfm is missing some "
		            + "required fields:"+_mbSetupCfm.getInitializationErrorString());
		    return;
		}
	}
	
	public int getServerMediaPort()
	{
	    return _mbSetupCfm.getServerMediaPort();
	}
	
	public InetAddress getServerMediaAddress()
	{
	    try
        {
            InetAddress address = InetAddress.getByAddress(
                    _mbSetupCfm.getServerMediaAddress().toByteArray());
            return address;
        } catch (UnknownHostException e)
        {
            logger.errorException(e);
            return null;
        }
	}
}
